package com.gzck.gzck_verson2.controller;


import com.gzck.gzck_verson2.pojo.GSensorParaInfo;
import com.gzck.gzck_verson2.pojo.GSensorParaRelation;
import com.gzck.gzck_verson2.service.IGSensorParaInfoService;
import com.gzck.gzck_verson2.service.IGSensorParaRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 计算关系表 前端控制器
 * </p>
 *
 * @author 任永辉
 * @since 2024-01-27
 */
@RestController
@RequestMapping("/g-sensor-para-relation")
public class GSensorParaRelationController {

    @Autowired
    private IGSensorParaRelationService sensorParaInfoService;

    // 添加计算关系表
    @PostMapping("/add")
    public boolean addSensorParaInfo(@RequestBody GSensorParaRelation sensorParaInfo) {
        return sensorParaInfoService.save(sensorParaInfo);
    }

    // 删除
    @DeleteMapping("/delete/{id}")
    public boolean deleteSensorParaInfo(@PathVariable Long id) {
        return sensorParaInfoService.removeById(id);
    }

    // 更新
    @PutMapping("/update")
    public boolean updateSensorParaInfo(@RequestBody GSensorParaRelation sensorParaInfo) {
        return sensorParaInfoService.updateById(sensorParaInfo);
    }

    // 查询
    @GetMapping("/{id}")
    public GSensorParaRelation getSensorParaInfo(@PathVariable Long id) {
        return sensorParaInfoService.getById(id);
    }

    // 查询所有
    @GetMapping("/all")
    public List<GSensorParaRelation> getAllSensorParaInfos() {
        return sensorParaInfoService.list();
    }
}
